import { Injectable, NestMiddleware } from '@nestjs/common';
import { Response } from 'express';


@Injectable()
export class AppMiddleware implements NestMiddleware {

  use(req: any, res: Response, next: Function) {
    /* 用户唯一id */
    req.visitorid = req.headers.visitorid
    /* 包号 */
    if (/\/\/(\d)/.test(req.headers.origin)) {
      req.dns = parseInt(req.headers.origin.match(/\/\/(\d*)/)[1])
      next();
    }
  }
}
